|
|
 |
|
|
|
|
client. The IFileSubsystem class is the interface for the subsystem, making sure that the proper response to an incoming event or message is handled as expected. The IPersistence class instance (or object) owns a reference to the IFileSubsystem class instance. This object, in turn, owns a reference to an instance of a GeneralFile interface implementation class such as RandomFile, SequentialFile, BinaryFile, or RichTextFile. One of these classes does the actual grunt work. Note that the GeneralFile class is purely an interface class that abstracts the common interface between the four implementation classes. |
|
|
|
 |
|
|
|
|
10. Explain the persistNewInfo and persistAddedInfo methods of the GeneralFile family of classes. |
|
|
|
 |
|
|
|
|
The persistNewInfo method saves information to a file that did not exist before, whereas the persistAddedInfo method adds information to a previously existing file. For SequentialFile objects, the file has to be opened in Append mode. |
|
|
|
 |
|
|
|
|
1. True or False: Every significant class method and code module function (if any) requires initial error handling. |
|
|
|
 |
|
|
|
|
True |
|
|
|
 |
|
|
|
|
2. What three steps are typically involved in implementing inline error handling in your methods? |
|
|
|
 |
|
|
|
|
The steps are as follows: |
|
|
|
 |
|
|
|
|
1. Enable the error trap (equivalent to throwing an exception). |
|
|
|
 |
|
|
|
|
2. Respond to the error (equivalent to catching an exception). |
|
|
|
 |
|
|
|
|
3. Complete the error-handling process and, if possible, continue program execution. |
|
|
|
 |
|
|
|
|
3. What statement initiates your error traps? |
|
|
|
 |
|
|
|
|
The On Error statement initiates your error traps, specifying to which label the application should go to perform the beginning of the error-handling routine. |
|
|
|
 |
|
|
|
|
4. Is it okay to do very complex error handling in every method? |
|
|
|
 |
|
|
|
|
No. It's advisable not to do too much complex error handling within a method as this could clutter your method code and make it difficult to debug. Besides, you want to be able to reuse sophisticated error-handling routines throughout your application. |
|
|
|
|
|